/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sdr.elementos;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import org.hibernate.Session;
import sdr.HibernateUtil;

/**
 *
 * @author stevenlizarazo
 */
@Entity
public 
 class ubicacion implements Serializable {

    @Id
@GeneratedValue(strategy = GenerationType.AUTO)

    private int id=0;
private String nombre="";
private double latitud=0;
private double longitud=0;
        @ManyToOne
private tipo_de_interes tipo;
    @ManyToOne
private usuario usuario;
    
public String getNombre(){ return nombre;}
public double getLatitud(){ return latitud;}
public double getLongitud(){return longitud;}
public tipo_de_interes getTipo(){return tipo;}
public usuario getUsuario(){return usuario;}

   public int getId(){return id;}

public void setNombre(String n){  nombre=n;}
public void setLatitud(double c){  latitud=c;}
public void setLongitud(double p){longitud=p;}
public void setTipo(tipo_de_interes p){tipo=p;}
public void setUsuario(usuario p){usuario=p;}
public void setId(int i){id=i;}



public void save(){

 Session hsession = HibernateUtil.getSessionFactory().getCurrentSession();
        hsession.beginTransaction();

        hsession.save(this);

        hsession.getTransaction().commit();  
}

public void update(){

 Session hsession = HibernateUtil.getSessionFactory().getCurrentSession();
        hsession.beginTransaction();

        hsession.update(this);

        hsession.getTransaction().commit();  
}



public void delete(){

 Session hsession = HibernateUtil.getSessionFactory().getCurrentSession();
        hsession.beginTransaction();

        hsession.delete(this);

        hsession.getTransaction().commit();  
}
}

